import { defineStore } from 'pinia'
import { ref } from 'vue'
import { articleAPI } from '@/apis/article.js'
import { ElMessage } from 'element-plus'
import Login from "@/views/UserIdentity/Login.vue";

export const useArticleStore = defineStore('article', () => {
  // 状态
  const boards = ref([])

  // 获取板块信息
  const fetchBoards = async () => {
    try {
      const response = await articleAPI.getBoards()
      if (response.status === 'success') {
        boards.value = response.data || []
        return response
      }
    } catch (error) {
      console.log(error)
    }
  }

  return {
    // 状态
    boards,
    
    // 方法
    fetchBoards,
  }
}, {
  persist: true
})